package com.wgw;

import com.wgw.config.AppConfig;
import com.wgw.task.TimePrintTask;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.util.concurrent.ThreadPoolExecutor;

public class App {
    public static void main(String[] args) {
        // 加载Spring注解配置
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        // 获取线程池和任务实例
        ThreadPoolExecutor executor = context.getBean(ThreadPoolExecutor.class);
        TimePrintTask task = context.getBean(TimePrintTask.class);

        // 提交任务到线程池执行
        executor.submit(task);

        // 关闭Spring上下文（程序会继续运行直到任务完成）
        // context.close();
    }
}